<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>用户登录</title>
		<link rel="icon" href="../img/favicon.ico" type="images/x-ico" />

		<link rel="stylesheet" href="../css/login.css">
		<script src="../fonts/iconfont1.js"></script>
		<script src="../fonts/iconfont2.js"></script>

	</head>
	<body>
		<div class="container">
			<div class="formbox">
				<div class="loginbox">

					<svg class="iicon" aria-hidden="true"><use xlink:href="#icon-gerenzhongxin"></use></svg>
					<h1>用户登录</h1>
					<div class="inputemail">
						<svg class="icon" aria-hidden="true"><use xlink:href="#icon-youjian"></use></svg>
						<span class="iconfont icon-youjian"></span>
						<span>:</span>
						<input id="l_email" type="email" name="email" onblur="checke1()"  placeholder="用户邮箱">
						<svg class="icon" aria-hidden="true"><use xlink:href="#icon-bitian"></use></svg>
						<br><span id="lemailmsg" style="font-size: 12px;" >&nbsp;</span>
					</div>
					<div class="verifycode">
						<svg class="icon" aria-h idden="true"><use xlink:href="#icon-yanzhengma"></use></svg>
						<span>:</span>
						<input class="code" id="l_code" type="text" name="code" onblur="checkc1()"" placeholder="验证码">
						<svg class="icon" aria-hidden="true"><use xlink:href="#icon-bitian"></use></svg>
						<button id="l_scode" type="submit">发送验证码</button>
						<br><span id="lcodemsg" style="font-size: 12px;" >&nbsp;</span>
					</div>
					<div class="password">
						<svg class="icon" aria-hidden="true"><use xlink:href="#icon-password"></use></svg>
						<span>:</span>
						<input id="l_password" type="password" name="password" onblur="checkp1()"" placeholder="密码">
						<svg class="icon" aria-hidden="true"><use xlink:href="#icon-bitian"></use></svg>
						<br><span id="lpasswordmsg" style="font-size: 12px;" >&nbsp;</span>
					</div>
					<button id="login" type="submit">登录</button>
					<div class="nullbutton">
						<button id="toregister">注册</button>
						<button id="toreset">忘记密码？</button>
					</div>
				</div>
				<div class="registerbox  hidden">
					<svg class="iicon" aria-hidden="true"><use xlink:href="#icon-gerenzhongxin"></use></svg>
					<h1>用户注册</h1>
					<div class="inputemail">
						
						<svg class="icon" aria-hidden="true"><use xlink:href="#icon-youjian"></use></svg>
						<span>:</span>
						<input id="r_email" type="email" name="email"  onblur="checke2()" placeholder="用户邮箱">
						<svg class="icon" aria-hidden="true"><use xlink:href="#icon-bitian"></use></svg>
						<br><span id="r_emailmsg" style="font-size: 12px;" >&nbsp;</span>
					</div>
					<div class="verifycode">
						<svg class="icon" aria-hidden="true"><use xlink:href="#icon-yanzhengma"></use></svg>
						<span>:</span>
						<input class="code" id="r_code" name="code" type="text" onblur="checkc2()" placeholder="验证码">
						<svg class="icon" aria-hidden="true"><use xlink:href="#icon-bitian"></use></svg>
						<button id="r_scode" type="submit">发送验证码</button>
						<br><span id="r_codemsg" style="font-size: 12px;" >&nbsp;</span>
					</div>
					<div class="password">
						<svg class="icon" aria-hidden="true"><use xlink:href="#icon-password"></use></svg>
						<span>:</span>
						<input id="r_password1" name="password" type="password" onblur="checkp2()" placeholder="密码">
						<svg class="icon" aria-hidden="true"><use xlink:href="#icon-bitian"></use></svg>
						<br><span id="r_password1msg" style="font-size: 12px;color:green;" >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;6-16位字母和数字组合</span>
					</div>
					<div class="password">
						<svg class="icon" aria-hidden="true"><use xlink:href="#icon-password"></use></svg>
						<span>:</span>
						<input id="r_password2" name="password" type="password" onblur="checkp2()" placeholder="重复密码">
						<svg class="icon" aria-hidden="true"><use xlink:href="#icon-bitian"></use></svg>
						<br><span id="r_password2msg" style="font-size: 12px;" >&nbsp;</span>
					</div>
					<button id="register"  type="submit">注册</button>
					<div class="nulllbutton">
						<button id="rtologin">登录</button>
					</div>
				</div>
				<div class="resetbox hidden">
					<svg class="icon" aria-hidden="true"><use xlink:href="#icon-pojiexiugai"></use></svg>
					<h1>重置密码</h1>
					<div class="inputemail">
						<svg class="icon" aria-hidden="true"><use xlink:href="#icon-youjian"></use></svg>
						<span>:</span>
						<input id="re_email" type="email" name="email" onblur="checke3()" placeholder="用户邮箱">
						<svg class="icon" aria-hidden="true"><use xlink:href="#icon-bitian"></use></svg>
						<br><span id="re_emailmsg" style="font-size: 12px;" >&nbsp;</span>
					</div>
					<div class="verifycode">
						<svg class="icon" aria-hidden="true"><use xlink:href="#icon-yanzhengma"></use></svg>
						<span>:</span>
						<input class="code" id="re_code" type="text" name="code" onblur="checkc3()" placeholder="验证码">
						<svg class="icon" aria-hidden="true"><use xlink:href="#icon-bitian"></use></svg>
						<button id="re_scode" type="submit">发送验证码</button>
						<br><span id="re_codemsg" style="font-size: 12px;" >&nbsp;</span>
					</div>
					<div class="password">
						<svg class="icon" aria-hidden="true"><use xlink:href="#icon-password"></use></svg>
						<span>:</span>
						<input id="re_password1" type="password" name="password" onblur="checkp3()" placeholder="密码">
						<svg class="icon" aria-hidden="true"><use xlink:href="#icon-bitian"></use></svg>
						<br><span id="re_password1msg" style="font-size: 12px;color: green;" >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;6-16位字母和数字组合</span>
					</div>
					<div class="password">
						<svg class="icon" aria-hidden="true"><use xlink:href="#icon-password"></use></svg>
						<span>:</span>
						<input id="re_password2" type="password" name="password" onblur="checkp3()" placeholder="重复密码">
						<svg class="icon" aria-hidden="true"><use xlink:href="#icon-bitian"></use></svg>
						<br><span id="re_password2msg" style="font-size: 12px;" >&nbsp;</span>
					</div>
					<button id="reset" type="submit" >重置密码</button>
					<div class="nulllbutton">
						<button id="retologin">登录</button>
					</div>
					
				</div>
				
			</div>
			<div class="conbox left">
				<h2 style="letter-spacing: 5px;font-size: 33px;">欢迎登陆云药房<br>医药管理系统</h2>
				<img src="../img/药房 (1).png" alt="">
					
			</div>
			<div class="conbox right">
				
				<h2 style="letter-spacing: 5px;font-size: 33px;">欢迎登陆云药房<br>医药管理系统</h2>
			<img src="../img/药房 (1).png" alt="">
				
			</div>
		</div>
	</body>
	
	<script type="text/javascript">
	    // 要操作到的元素
	    let toregister=document.getElementById('toregister');
		let toreset=document.getElementById('toreset');
		let rtologin=document.getElementById('rtologin')
		let retologin=document.getElementById('retologin')
	    let formbox=document.getElementsByClassName('formbox')[0];
	    let registerbox=document.getElementsByClassName('registerbox')[0];
	    let loginbox=document.getElementsByClassName('loginbox')[0];
		let resetbox=document.getElementsByClassName('resetbox')[0];
	    // 去注册按钮点击事件
	    toregister.addEventListener('click',()=>{
	        formbox.style.transform='translateX(80%)';
	        loginbox.classList.add('hidden');
	        registerbox.classList.remove('hidden');
	    })
	    // 去登录按钮点击事件
	    rtologin.addEventListener('click',()=>{
	        formbox.style.transform='translateX(0%)';
			registerbox.classList.add('hidden');
	        loginbox.classList.remove('hidden');
	    })
		retologin.addEventListener('click',()=>{
		    formbox.style.transform='translateX(0%)';
			resetbox.classList.add('hidden');
		    loginbox.classList.remove('hidden');
		})
		toreset.addEventListener('click',()=>{
		    formbox.style.transform='translateX(80%)';
		    loginbox.classList.add('hidden');
		    resetbox.classList.remove('hidden');
		})
		//检验输入数据
		//邮箱的验证
		function checke1(){
			  var email= document.getElementById('l_email');
			  var emailmsg = document.getElementById('lemailmsg');
			  var reg = /^\w*@[-a-zA-Z0-9]{1,20}\.[0-9a-z]{2,3}$/;     //检测邮箱  
			  if(email.value.length==0){
				  emailmsg.innerHTML = '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;邮箱不得为空';
				  emailmsg.style.color='red';
				  return false;
			  }
			 else if(!reg.test(email.value)){
				emailmsg.innerHTML = '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;邮箱格式不正确';
				emailmsg.style.color='red';
				return false;
			  }
			  else{
				emailmsg.innerHTML = '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;邮箱格式符合要求';
				emailmsg.style.color='green';
				return true;
			  }
		}
		function checkp1(){
		  var password= document.getElementById('l_password');
			var passwordmsg= document.getElementById('lpasswordmsg');
		  var reg =/^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{6,16}$/;
		  if(password.value.length==0){
		      passwordmsg.innerHTML = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;密码不得为空";
		     passwordmsg.style.color='red';
			 return false;
		  }else if(!reg.test(password.value)){
		      passwordmsg.innerHTML = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;请输入6-16位数字和字母组合的密码";
		     passwordmsg.style.color='red';
			 return false;
		  }else {
		      passwordmsg.innerHTML = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;密码格式符合要求";
		      passwordmsg.style.color='green';
			  return true;
		  }
		}
		function checkc1(){
		  var code= document.getElementById('l_code');
			var codemsg= document.getElementById('lcodemsg');
			if(code.value.length==0){
			    codemsg.innerHTML = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;验证码不得为空";
			   codemsg.style.color='red';
			   return false;
			}
		 else if(code.value.length!=6){
		      codemsg.innerHTML = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;验证码必须为6位";
		     codemsg.style.color='red';
			 return false;
		  }else {
		      codemsg.innerHTML = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;验证码格式符合要求";
		      codemsg.style.color='green';
			  
		  }
		  return true;
		}
		
		function checke2(){
			  var email= document.getElementById('r_email');
			  var emailmsg = document.getElementById('r_emailmsg');
			  var reg = /^\w*@[-a-zA-Z0-9]{1,20}\.[0-9a-z]{2,3}$/;     //检测邮箱  
			  if(email.value.length=0){
			  				  emailmsg.innerHTML = '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;邮箱不得为空';
			  				  emailmsg.style.color='red';
							  return false;
			   }
			  else if(!reg.test(email.value)){
				emailmsg.innerHTML = '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;邮箱格式不正确';
				emailmsg.style.color='red';
				return false;
			  }
			  else{
				emailmsg.innerHTML = '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;邮箱格式符合要求';
				emailmsg.style.color='green';
				return true;
			  }
		}
		function checkc2(){
		  var code= document.getElementById('r_code');
			var codemsg= document.getElementById('r_codemsg');
			if(code.value.length==0){
						    codemsg.innerHTML = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;验证码不得为空";
						   codemsg.style.color='red';
						   return false;
						}
			else if(code.value.length!=6){
		      codemsg.innerHTML = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;验证码必须为6位";
		     codemsg.style.color='red';
			 return false;
		  }else {
		      codemsg.innerHTML = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;验证码格式符合要求";
		      codemsg.style.color='green';
			  return true;
		  }
		}
		function checkp2(){
		  var password1= document.getElementById('r_password1');
			var passwordmsg1= document.getElementById('r_password1msg');
			var password2= document.getElementById('r_password2');
			var passwordmsg2= document.getElementById('r_password2msg');
		  var reg =/^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{6,16}$/;
		  if(password1.value.length==0){
		      passwordmsg1.innerHTML = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;密码不得为空";
		     passwordmsg1.style.color='red';
			 return false;
		  }else if(!reg.test(password1.value)){
		      passwordmsg1.innerHTML = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;请输入6-16位数字和字母组合的密码";
		     passwordmsg1.style.color='red';
			 return false;
		  }else {
		      passwordmsg1.innerHTML = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;密码格式符合要求";
		      passwordmsg1.style.color='green';
		  }
		  if(password2.value.length==0){
		      passwordmsg2.innerHTML = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;请重复输入密码";
		     passwordmsg2.style.color='red';
			 return false;
		  }else if(password2.value!=password1.value)
		  {
			  passwordmsg2.innerHTML = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;两次密码输入不一致";
			  passwordmsg2.style.color='red';
			  return false;
		  }else{
			  passwordmsg2.innerHTML = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;两次密码输入一致";
			  passwordmsg2.style.color='green';
		  }
		  return true;
		}
		function checke3(){
			  var email= document.getElementById('re_email');
			  var emailmsg = document.getElementById('re_emailmsg');
			  var reg = /^\w*@[-a-zA-Z0-9]{1,20}\.[0-9a-z]{2,3}$/;     //检测邮箱  
			  if(email.value.length=0){
			  				  emailmsg.innerHTML = '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;邮箱不得为空';
			  				  emailmsg.style.color='red';
							  return false;
			   }
			  else if(!reg.test(email.value)){
				emailmsg.innerHTML = '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;邮箱格式不正确';
				emailmsg.style.color='red';
				return false;
			  }
			  else{
				emailmsg.innerHTML = '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;邮箱格式符合要求';
				emailmsg.style.color='green';
				return true;
			  }
		}
		function checkc3(){
		  var code= document.getElementById('re_code');
			var codemsg= document.getElementById('re_codemsg');
			if(code.value.length==0){
						    codemsg.innerHTML = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;验证码不得为空";
						   codemsg.style.color='red';
						   return false;
						}
			else if(code.value.length!=6){
		      codemsg.innerHTML = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;验证码必须为6位";
		     codemsg.style.color='red';
			 return false;
		  }else {
		      codemsg.innerHTML = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;验证码格式符合要求";
		      codemsg.style.color='green';
			  return true;
			  }
		}
		function checkp3(){
		  var password1= document.getElementById('re_password1');
			var passwordmsg1= document.getElementById('re_password1msg');
			var password2= document.getElementById('re_password2');
			var passwordmsg2= document.getElementById('re_password2msg');
		  var reg =/^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{6,16}$/;
		  if(password1.value.length==0){
		      passwordmsg1.innerHTML = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;密码不得为空";
		     passwordmsg1.style.color='red';
			 return false;
		  }else if(!reg.test(password1.value)){
		      passwordmsg1.innerHTML = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;请输入6-16位数字和字母组合的密码";
		     passwordmsg1.style.color='red';
			 return false;
		  }else {
		     passwordmsg1.innerHTML = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;密码格式符合要求";
		     passwordmsg1.style.color='green';
		  }
		  if(password2.value.length==0){
		      passwordmsg2.innerHTML = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;请重复输入密码";
		     passwordmsg2.style.color='red';
			 return false;
		  }else if(password2.value!=password1.value)
		  {
			  passwordmsg2.innerHTML = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;两次密码输入不一致";
			  passwordmsg2.style.color='red';
			  return false;
		  }else{
			  passwordmsg2.innerHTML = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;两次密码输入一致";
			  passwordmsg2.style.color='green';
			  return true;
		  }
		}
		var lscode=document.getElementById('l_scode');
		var rscode=document.getElementById('r_scode');
		var rescode=document.getElementById('re_scode');
		var login=document.getElementById('login');
		var register=document.getElementById('register');
		var reset=document.getElementById('reset');
		lscode.addEventListener('click',()=>{
			if(!checke1()){
				alert("请按要求填写邮箱");
				return ;
			}
			var email=document.getElementById('l_email').value;
			var xhr=new XMLHttpRequest();
			xhr.open('POST','http://127.0.0.1:8000/api/sendcode');
			xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
			xhr.send('email='+email);
			console.log(email)
			xhr.onreadystatechange=function(){
				if(this.readyState==4&&this.status==200){
					console.log(xhr.responseText)
					if(xhr.responseText.indexOf(true)+2){
						var theNeww =JSON.parse(xhr.responseText);
						if(theNeww.status==0){
							alert("已发送验证码");
						}else if(theNeww.status==1){
							alert("未能成功发送");
						}
					}
				}
			}
		});
		rscode.addEventListener('click',()=>{
			if(!checke2()){
				alert("请按要求填写邮箱");
				return ;
			}
			var email=document.getElementById('r_email').value;
			var xhr=new XMLHttpRequest();
			xhr.open('POST','http://127.0.0.1:8000/api/sendcode');
			xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
			xhr.send('email='+email);
			console.log(email)
			xhr.onreadystatechange=function(){
				if(this.readyState==4&&this.status==200){
					console.log(xhr.responseText)
					if(xhr.responseText.indexOf(true)+2){
						var theNeww =JSON.parse(xhr.responseText);
						if(theNeww.status==0){
							alert("已发送验证码");
						}else if(theNeww.status==1){
							alert("未能成功发送");
						}
					}
				}
			}
		});
		rescode.addEventListener('click',()=>{
			if(!checke3()){
				alert("请按要求填写邮箱");
				return ;
			}
			var email=document.getElementById('re_email').value;
			var xhr=new XMLHttpRequest();
			xhr.open('POST','http://127.0.0.1:8000/api/sendcode');
			xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
			xhr.send('email='+email);
			console.log(email)
			xhr.onreadystatechange=function(){
				if(this.readyState==4&&this.status==200){
					console.log(xhr.responseText)
					if(xhr.responseText.indexOf(true)+2){
						if(xhr.responseText.indexOf(true)+2){
						var theNeww =JSON.parse(xhr.responseText);
						if(theNeww.status==0){
							alert("已发送验证码");
						}else if(theNeww.status==1){
							alert("未能成功发送");
						}
					}
					}
				}
			}
		});
		login.addEventListener('click',()=>{
			
			if(!(checke1()&&checkc1()&&checkp1())){alert("请按要求完整填写后再提交");return ;}
			var l_email=document.getElementById('l_email').value;
			var l_code=document.getElementById('l_code').value;
			var l_password=document.getElementById('l_password').value;
			var xhr=new XMLHttpRequest();
			xhr.open('POST','http://127.0.0.1:8000/api/login');
			xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
			console.log(l_email);
			console.log(l_code);
			console.log(l_password);
			xhr.send('email='+l_email+'&code='+l_code+'&password='+l_password);
			xhr.onreadystatechange=function(){
				if(this.readyState==4&&this.status==200){
					var theNeww =JSON.parse(xhr.responseText);
						window.localStorage.setItem('token',theNeww.token);
						if(theNeww.status==0){
							
							window.location.href="http://127.0.0.1:8000/home"
						}else if(theNeww.status==1){
							alert("未能成功登录");
						}
					if(xhr.responseText.indexOf(true)+2){
						
						
					}
				}
			}
		});
		register.addEventListener('click',()=>{
			
			if(!(checke2()&&checkc2()&&checkp2())){alert("请按要求完整填写后再提交");return ;}
			var email=document.getElementById('r_email').value;
			var code=document.getElementById('r_code').value;
			var password=document.getElementById('r_password1').value;
			var xhr=new XMLHttpRequest();
			xhr.open('POST','http://127.0.0.1:8000/api/regUser');
			xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
			console.log(email);
			console.log(code);
			console.log(password);
			xhr.send('email='+email+'&code='+code+'&password='+password);
			xhr.onreadystatechange=function(){
				if(this.readyState==4&&this.status==200){
					console.log(xhr.responseText)
					var theNeww =JSON.parse(xhr.responseText);
					
						if(theNeww.status==0){
							alert("注册成功");

						}else if(theNeww.status==1){
							alert("未能成功注册");
						}
					if(xhr.responseText.indexOf(true)+2){
						
					}
				}
			}
		});
		reset.addEventListener('click',()=>{
			
			if(!(checke3()&&checkc3()&&checkp3())){alert("请按要求完整填写后再提交");return ;}
			var email=document.getElementById('re_email').value;
			var code=document.getElementById('re_code').value;
			var password=document.getElementById('re_password1').value;
			var xhr=new XMLHttpRequest();
			xhr.open('POST','http://127.0.0.1:8000/api//resetpassword');
			xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
			console.log(email);
			console.log(code);
			console.log(password);
			xhr.send('email='+email+'&code='+code+'&password='+password);
			xhr.onreadystatechange=function(){
				if(this.readyState==4&&this.status==200){
					console.log(xhr.responseText)
					var theNeww =JSON.parse(xhr.responseText);
						if(theNeww.status==0){
							alert("重置密码成功");
						}else if(theNeww.status==1){
							alert("未能成功重置密码");
						}
					if(xhr.responseText.indexOf(true)+2){
						
					}
				}
			}
		});
	</script>
</html>